import React, { Component } from 'react'
import {connect} from "react-redux"
import axios from 'axios'
 class ShortVideo extends Component {
  componentDidMount(){
    console.log(this.props,1111);
    this.props.getlIST()
  }
  render() {
    console.log(this.props,"ascdasxsx")
    return (
      <div>
        {
          this.props.list && this.props.list.length ?  this.props.list.map((item,index)=>{
                return <div key={index}>
                    <span>{item.name}</span>
                </div>
          }):"暂无数据"
        }
      </div>
    )
  }
}
let mapStatetOPROPS = (state)=>{ //将仓库数据提供组件
    console.log(state,"satte");
    return {
      ...state
    }
}

let  mapDispatchToProps  = (dispatch) =>{  // 将dispatc
    return {
       getlIST(){
         axios.get("/list").then(res=>{
            dispatch({
              type:"getList",
              paylaod:res.data
            })
         })
       }
    }
}
export default connect(mapStatetOPROPS,mapDispatchToProps)(ShortVideo)